package payroll.classfication;

import java.util.LinkedHashMap;
import java.util.Map;

public class HourlyClassification implements PaymentClassfication {
     private double hourlyRate;
     private Map<String,TimeCard> timeCards = new LinkedHashMap<>();
     public HourlyClassification(double hourlyRate) {
        
        this.hourlyRate = hourlyRate;
    }


     public double getHourlyRate() {
       return hourlyRate;
     }


     public TimeCard getTimeCardofDate(String date) {
      return timeCards.get(date);

        
     }


     public void addTimeCard(TimeCard tc) {
      timeCards.put(tc.getDate(), tc);
    
}

    @Override
    public double calculatePay() {
        double total=0;
        for(TimeCard tc:timeCards.values())
        if (tc.getHours()<=8) 

            total+=tc.getHours()*hourlyRate;
        else
            total+=(8*hourlyRate)+(tc.getHours()-8)*1.5*hourlyRate;
        return total;
            
        
            
}}